import request from "../../utils/request";

const GOODS_BASE = "maimao_goods/goods/order";
const ORDER_BASE = "maimao_order/order";
const EXCEL_BASE = "maimao_order/excel";
export default {

    /**
     * 确认订单列表
     */
    confirmOrderData(carIds) {
        return request({
            url: `${GOODS_BASE}/confirm-order`,
            method: 'post',
            data: {
                carIds
            }
        })
    },
    /**
     * 普通订单提交
     */
    commitOrder(data) {
        return request({
            url: `${ORDER_BASE}/submit`,
            method: 'post',
            data: data
        })
    },

    checkOrder(orderId) {
        return request({
            url: `${ORDER_BASE}/check-order/${orderId}`,
            method: 'get'
        })
    },
    pay(orderId) {
        return request({
            url: `${ORDER_BASE}/pay`,
            method: 'post',
            data: {
                orderId
            }
        })
    },
    test() {
        return request({
            url: `${ORDER_BASE}/cancel`,
            method: 'post',
        })
    },

    /**
     * 查询用户订单列表
     */
    queryUserOrderList(page, size, searchData) {
        return request({
            url: `${ORDER_BASE}/user-order?page=${page}&size=${size}`,
            method: "post",
            data: searchData
        })
    },
    /**
     * 查询卖家订单列表
     */
    queryShopOrderList(page, size, searchData) {
        return request({
            url: `${ORDER_BASE}/shop-order?page=${page}&size=${size}`,
            method: "post",
            data: searchData
        })
    },

    /**
     * 删除订单
     */
    deleteOrder(orderId) {
        return request({
            url: `${ORDER_BASE}/delete`,
            method: 'post',
            data: {
                orderId,
            }
        })
    },

    /**
     * 卖家发货
     * @param id
     * @returns {AxiosPromise}
     */
    delivery(id, orderShopId, orderId) {
        return request({
            url: `${ORDER_BASE}/delivery`,
            method: 'post',
            data: {
                id,
                orderShopId,
                orderId
            }
        })
    },
    /**
     * 收货
     * @param id
     * @returns {AxiosPromise}
     */
    receiveGoods(id, orderShopId) {
        return request({
            url: `${ORDER_BASE}/check-receive`,
            method: 'post',
            data: {
                id,
                orderShopId
            }
        })
    },

    /**
     * 查询是否已经评论过
     * @param skuId
     * @param orderId
     * @returns {AxiosPromise}
     */
    isComment(input) {
        return request({
            url: `${ORDER_BASE}/comment-status`,
            method: 'post',
            data: input
        })
    },

    exportOrder(input, page, size) {
        return request({
            url: `${EXCEL_BASE}/export?page=${page}&size=${size}`,
            method: 'post',
            data: input,
            responseType: "blob"
        })
    }


}

